<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/header.jsp"%>
<%@taglib prefix="code" tagdir="/WEB-INF/tags"%>

<div style="margin:20px 0;"></div>
<div class="easyui-panel">
	<div style="padding:10px 60px 20px 60px">
	<form id="headAdvForm"  name="headAdvForm" method="post" action="<c:url value='/headAdv/saveHeadAdvDetail.do'/>">
	<input type="hidden" id="adv_uuid" name="adv_uuid" value="${headAdvMap.adv_uuid}"/>
	<input type="hidden" id="ins_uuid" name="ins_uuid" value="${headAdvMap.ins_uuid}"/>
	<input type="hidden" id="rec_id" name="rec_id" value="${headAdvMap.rec_id}"/>
			<table cellpadding="5" style="width:100%">
				<tr>
					<td>所属机构:</td>
					<td>
						<input class="easyui-textbox" type="text"  data-options="required:true" readonly="readonly" id="inst_name" value="${headAdvMap.inst_name}"/>
						<a href="javascript:void(0)" class="easyui-linkbutton detail-remove" iconCls="icon-search" id="selelctBtn">选择</a>
					</td>
				</tr>
				<tr>
					<td>广告标题:</td>
					<td><input class="easyui-textbox" type="text"  name="adv_title" data-options="required:true,validType:['length[0,120]']" value="${headAdvMap.adv_title}"></input></td>
					<td>头部广告图片编号:</td>
					<td><input class="easyui-textbox" type="text"  name="adv_no" data-options="required:true,validType:['advNo']" value="${headAdvMap.adv_no}"></input></td>
				</tr>
				<tr>
					<td>广告事件类型:</td>
					<td><code:codeSelect id="adv_type" name="adv_type" showSelect="true" code_type="ADV_TYPE" selectId="${headAdvMap.adv_type}"></code:codeSelect></td>
					<%--<td><input class="easyui-textbox" type="text"  name="headpic_path"  data-options="required:true,validType:['length[0,120]']"  value="${infEntity.headpic_path}"></input></td>--%>
				</tr>
				<tr>
					<td>事件点击后的响应地址:</td>
					<td><input class="easyui-textbox" type="text"  name="event_path"  data-options="validType:['length[0,120]']"  value="${headAdvMap.event_path}"></input></td>
					<td>广告位位置:</td>
					<td><code:codeSelect id="adv_place" name="adv_place" showSelect="true" code_type="ADV_PLACE" selectId="${headAdvMap.adv_place}"></code:codeSelect></td>
				</tr>
				<tr>
					<td>安卓广告图片:</td>
					<td>
						<div class="uploader uploader-file detail-remove" uploadType="0" affixType="4" storeType="1" affixIdx ="${headAdvMap.adv_uuid}"></div>
					</td>
				</tr>

				<tr>
					<td>IOS2X广告图片:</td>
					<td>
						<div class="uploader uploader-file detail-remove" uploadType="0" affixType="4" storeType="2" affixIdx ="${headAdvMap.adv_uuid}"></div>
					</td>
				</tr>
				<tr>
					<td>IOS3X广告图片:</td>
					<td>
						<div class="uploader uploader-file detail-remove" uploadType="0" affixType="4" storeType="3" affixIdx ="${headAdvMap.adv_uuid}"></div>
					</td>
				</tr>
	</table>
	<div style="text-align:center;padding:5px">
		<a href="javascript:void(0)" class="easyui-linkbutton btn detail-remove" iconCls="icon-save" onclick="submitForm('headAdvForm')">保存</a>
		<a href="javascript:void(0)" class="easyui-linkbutton btn" iconCls="icon-back" onclick="back()">返回</a>
	</div>
</form>
	</div>
</div>
<div id="menuTree">
	<div id="ztreeObj" class="ztree"></div>
</div>
<script>
    $.extend($.fn.textbox.defaults.rules, {
        advNo: {
            validator: function(value){
                var reg = new RegExp("^[0-9a-zA-Z_]{0,10}$");
                return reg.test(value);
            },
            message: '内容长度不能超过{10},且必须为数字或字母!'
        }

    });
    var ztreeObj;
    /*选择按钮*/
    $("#selelctBtn").click(function(){
        ztreeObj = showAppTree(selected, $("#ins_uuid").val());
    });

    /*确定按钮回调*/
    function selected(){
        var nodes = ztreeObj.getSelectedNodes();
        console.log(nodes);
        if(nodes && nodes.length > 0){
            $("#inst_name").textbox("setValue", nodes[0].NAME);
            $("#ins_uuid").val(nodes[0].ID);
        }
    }
    function showAppTree(confirmCallback, uuid, option){
        var options = {
            url: "../organization/getAppInfTree.do",
            title: "选择机构",
            confirmCallback: confirmCallback,
            openIds: uuid,
            showSearch: true,
            searchTitle: "机构代码/名称"
        };
        options = $.extend({}, options, option);
        return showTree(options);
    }
    function showTree(options){
        var jpTree = $().jpTree(options);
        return jpTree;
    }

	/*$(function(){
        uploader("#headpic_file", {
            pick: "#headpic_btn",
            hiddenEl: "#headpic_path1",
            hiddenEl: "#headpic_path2",
            hiddenEl: "#headpic_path3",
            uploadType: 0
        });
	})*/

</script>